﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Maxleaf.EDI.API.Contract;
using Maxleaf.EDI.API.Contract.Client.Parameters;
using Maxleaf.EDI.Infrastructure;

namespace Maxleaf.EDI.Client.ExternalServices
{
    public class ClientService :IClientService
    {
        public AuthenticateResult Authenticate(AuthenticateParameters parameters)
        {
            using (var client = this.GetClient())
            {
                return client.Proxy.Authenticate(parameters);
            }
        }

        private ServiceProxy<IClientService> GetClient()
        {
            var result = new ServiceProxy<IClientService>("Client.Point");

            return result;
        }

        public GetUserDBsResult GetUserDBs(GetUserDBsParameters parameters)
        {
            using (var client = this.GetClient())
            {
                return client.Proxy.GetUserDBs(parameters);
            }
        }


        public void ResetPassword(API.Contract.Client.Commands.ResetPasswordCommand command)
        {
            using (var client = this.GetClient())
            {
                client.Proxy.ResetPassword(command);
            }
        }
    }
}